package com.ophelisis.common.consts;

import java.util.ArrayList;
import java.util.List;

/**
 * 코드 상수
 * 
 * @author
 */
public interface ConstCode {
	public static final String thumbnailPrefix = "thumb_";
	public static final int thumbnailWidth = 100;
	public static final int thumbnailHeight = 120;
	
	/**
	 * AuthLevelType :: 사용자 권한 그룹 종류
	 */
	enum AuthLevelType {
		/*
		 * 시스템 기본 자용자인지 확인
		 * 
		 * [사용자 권한 구분] :: 1 ~ 9 1:3:5:7:9 {user:manager:subadmin:admin:sysadmin}
		 * sysadmin :: 9 :: 통합관리자 :: Full Embbeded Administrator admin :: 7 ::
		 * 운영관리자 :: Super Administrator subadmin :: 5 :: 서브관리자 :: Sub
		 * Administrator manager :: 3 :: 일반관리자 :: Manager user :: 1 :: 일반사용자 ::
		 * User
		 */

		/** sysadmin :: 9 :: 통합관리자 :: Full Embbeded Administrator */
		sysadmin("9", "통합관리자"),

		/** admin :: 7 :: 운영관리자 :: Super Administrator */
		admin("7", "운영관리자"),

		/** subadmin :: 5 :: 서브관리자 :: Sub Administrator */
		subadmin("5", "서브관리자"),

		/** manager :: 3 :: 일반관리자 :: Manager */
		manager("3", "일반관리자"),

		/** user :: 1 :: 일반사용자 :: User */
		user("1", "일반사용자"), ;

		private final String code;
		private final String description;

		AuthLevelType(String code, String description) {
			this.code = code;
			this.description = description;
		}

		public static AuthLevelType get(String code) {
			for (AuthLevelType constItem : AuthLevelType.values()) {
				if (constItem.getCode().equals(code)) {
					return constItem;
				}
			}
			return null;
		}

		public String getCode() {
			return code;
		}

		public String getDescription() {
			return description;
		}

		public String toString() {
			return getClass().getSimpleName() + "(" + code + ":" + description + ")";
		}
	}

	/**
	 * <pre>
	 * Method : ConstCode.MenuGNB()
	 * <br>
	 * menuId : 메뉴 ID
	 * groupId : 메뉴 그룹 ID
	 * name : 메뉴 이름
	 * action : 액션값
	 * auth : 열람 권한
	 * description : 설명
	 */
	enum MenuGNB {
		menu1("SA", "", "통합관리자 전용", "superAdministrator.action", "9", ""),
		menu2("MM", "", "포탈 관리", "userMgmt.action", "7", ""),
		menu3("UM", "", "사용자 관리", "userMgmt.action", "7", ""),

		item11("SA1", "SA", "공통 코드 관리", "commonCodeMgmt.action", "9", ""), 
		item12("SA2", "SA", "메뉴 관리", "menuMgmt.action", "9", ""),
		
		item21("MM1", "MM", "메뉴 권한 관리", "menuAuthMgmt.action", "7", ""), 
		item22("MM2", "MM", "메뉴 이미지 관리", "menuImageMgmt.action", "7", ""), 
		item23("MM3", "MM", "카테고리 관리", "categoryMgmt.action", "7", ""), 
		item24("MM4", "MM", "로고 관리", "logoMgmt.action", "7", ""), 

		item31("UM1", "UM", "포탈 사용자 관리", "portalUserMgmt.action", "7", ""), 
		item32("UM2", "UM", "홈페이지 사용자 관리", "clientUserMgmt.action", "7", ""), 
		;

		private final String menuId;
		private final String groupId;
		private final String name;
		private final String action;
		private final String auth;
		private final String description;

		MenuGNB(String menuId, String groupId, String name, String action, String auth, String description) {
			this.menuId = menuId;
			this.groupId = groupId;
			this.name = name;
			this.action = action;
			this.auth = auth;
			this.description = description;
		}

		public static List<MenuGNB> getMenuGroup() {
			List<MenuGNB> constItems = new ArrayList<MenuGNB>();
			for (MenuGNB constItem : MenuGNB.values()) {
				if (constItem.getGroupId().equals("")) {
					constItems.add(constItem);
				}
			}
			return constItems;
		}

		public static List<MenuGNB> getAllUpMenus() {
			List<MenuGNB> constItems = new ArrayList<MenuGNB>();
			for (MenuGNB constItem : MenuGNB.values()) {
				constItems.add(constItem);
			}
			return constItems;
		}

		public static List<MenuGNB> getMenus(String groupId) {
			List<MenuGNB> constItems = new ArrayList<MenuGNB>();
			for (MenuGNB constItem : MenuGNB.values()) {
				if (constItem.getGroupId().equals(groupId)) {
					constItems.add(constItem);
				}
			}
			return constItems;
		}

		public static MenuGNB get(String groupId) {
			for (MenuGNB constItem : MenuGNB.values()) {
				if (constItem.getMenuId().equals(groupId)) {
					return constItem;
				}
			}
			return null;
		}

		public String getMenuId() {
			return menuId;
		}

		public String getGroupId() {
			return groupId;
		}

		public String getName() {
			return name;
		}

		public String getAuth() {
			return auth;
		}

		public String getAction() {
			return action;
		}

		public String getDescription() {
			return description;
		}

		public String getValue() {
			return description;
		}

		public String toString() {
			return getClass().getSimpleName() 
					+ "(" + "menuId=" + menuId 
					+ ":" + "groupId=" + groupId 
					+ ":" + "name=" + name 
					+ ":" + "auth=" + auth 
					+ ":" + "action=" + action 
					+ ":" + "description=" + description 
					+ ")" + "\n";
		}
	}
	
	/**
	 * DefaultCodeGroup :: 코드 그룹 기본값
	 */
	enum DefaultCodeGroup {
		group1("메뉴 유형","관리자 포탈과 홈페이지에서 사용되는 메뉴 유형","Y"),
		;
		
		private final String groupNm;
		private final String groupDesc;
		private final String useYn;
		
		DefaultCodeGroup(String groupNm, String groupDesc, String useYn) {
			this.groupNm = groupNm;
			this.groupDesc = groupDesc;
			this.useYn = useYn;
		}
		
		public static List<DefaultCodeGroup> getAll() {
			List<DefaultCodeGroup> constItems = new ArrayList<DefaultCodeGroup> (); 
			for (DefaultCodeGroup constItem : DefaultCodeGroup.values()) {
				constItems.add(constItem);
			}
			return constItems;
		}

		public String getGroupNm() {
			return groupNm;
		}

		public String getGroupDesc() {
			return groupDesc;
		}

		public String getUseYn() {
			return useYn;
		}

		public String toString() {
			return getClass().getSimpleName() + "(" 
					+ "groupNm=" + groupNm + ":" 
					+ "groupDesc=" + groupDesc + ":" 
					+ "useYn=" + useYn + ":" 
					+ ")" + "\n";
		}
	}

	enum ColorSetLType {
		csl1("common.chart.ofcColorSetL1", "#04477E,0x424581"), 
		csl2("common.chart.ofcColorSetL2", "#6C24B8,0x424581"), 
		csl3("common.chart.ofcColorSetL3", "#B3B401,0x424581"), 
		csl4("common.chart.ofcColorSetL4", "#53A07E,0x424581"),
		csl5("common.chart.ofcColorSetL5", "#BA3330,0x424581"), 
		csl6("common.chart.ofcColorSetL6", "#F48801,0x424581"), 
		csl7("common.chart.ofcColorSetL7", "#5E72B7,0x424581"), 
		csl8("common.chart.ofcColorSetL8", "#C50398,0x424581"), 
		csl9("common.chart.ofcColorSetL9", "#808074,0x424581"), 
		csl10("common.chart.ofcColorSetL10", "#D50553,0x424581"),
		;

		private final String code;
		private final String description;

		ColorSetLType(String code, String description) {
			this.code = code;
			this.description = description;
		}

		public static ColorSetLType get(String code) {
			for (ColorSetLType constItem : ColorSetLType.values()) {
				if (constItem.getCode().equals(code)) {
					return constItem;
				}
			}
			return null;
		}

		public String getCode() {
			return code;
		}

		public String getDescription() {
			return description;
		}

		public String getValue() {
			return description;
		}

		public String toString() {
			return getClass().getSimpleName() + "(" + code + ":" + description + ")";
		}
	}

	enum ColorSetBarLType {
		csl1("common.chart.ofcColorSetBarL1", "#04477E"), 
		csl2("common.chart.ofcColorSetBarL2", "#6C24B8"), 
		csl3("common.chart.ofcColorSetBarL3", "#B3B401"), 
		csl4("common.chart.ofcColorSetBarL4", "#53A07E"), 
		csl5("common.chart.ofcColorSetBarL5", "#BA3330"), 
		csl6("common.chart.ofcColorSetBarL6", "#F48801"), 
		csl7("common.chart.ofcColorSetBarL7", "#5E72B7"), 
		csl8("common.chart.ofcColorSetBarL8", "#C50398"), 
		csl9("common.chart.ofcColorSetBarL9", "#808074"), 
		csl10("common.chart.ofcColorSetBarL10", "#D50553"), 
		;

		private final String code;
		private final String description;

		ColorSetBarLType(String code, String description) {
			this.code = code;
			this.description = description;
		}

		public static ColorSetBarLType get(String code) {
			for (ColorSetBarLType constItem : ColorSetBarLType.values()) {
				if (constItem.getCode().equals(code)) {
					return constItem;
				}
			}
			return null;
		}

		public String getCode() {
			return code;
		}

		public String getDescription() {
			return description;
		}

		public String getValue() {
			return description;
		}

		public String toString() {
			return getClass().getSimpleName() + "(" + code + ":" + description + ")";
		}
	}

	enum ChartItems {
		csl1("common.chart.ofcTitleColor", "#1C2CA6"), 
		csl2("common.chart.ofcYLegendColor", "#1C2CA6"), 
		csl3("common.chart.ofcBgColor", "#F2F2F2"), 
		csl4("common.chart.ofcXGridColor", "#DADADA"), 
		csl5("common.chart.ofcYGridColor", "#DADADA"), 
		csl6("common.chart.ofcXAxisColor", "0x799191"), 
		csl7("common.chart.ofcYAxisColor", "0x799191"), 
		csl8("common.chart.ofcInnerBgColor", "#F9F8F8,#A4A4A4,270"), 
		csl9("common.frame.left.size", "180"), 
		csl10("common.frame.top.size", "55"), 
		csl11("common.chart.ofcTitleSize", "12"), 
		csl12("common.chart.ofcYLegendSize", "12"), 
		csl13("common.chart.ofcYTicksSize", "4"), 
		csl14("common.chart.ofcYLabelSize", "14"), 
		csl15("common.chart.ofcXAxisSteps", "1"),
		;

		private final String code;
		private final String description;

		ChartItems(String code, String description) {
			this.code = code;
			this.description = description;
		}

		public static ChartItems get(String code) {
			for (ChartItems constItem : ChartItems.values()) {
				if (constItem.getCode().equals(code)) {
					return constItem;
				}
			}
			return null;
		}

		public String getCode() {
			return code;
		}

		public String getDescription() {
			return description;
		}

		public String getValue() {
			return description;
		}

		public int getIntValue() {
			try {
				return Integer.parseInt(description);
			} catch (Exception e) {
			}
			return 0;
		}

		public String toString() {
			return getClass().getSimpleName() + "(" + code + ":" + description + ")";
		}
	}
}
